package com.rxyb.security.gate.controller.reactive;

import cn.rxyb.core.respone.R;
import com.rxyb.security.gate.model.AddMenuRoleReq;
import com.rxyb.security.gate.model.AddMenuRoleRsp;
import com.rxyb.security.gate.model.MenuListReq;
import com.rxyb.security.gate.model.MenuListRsp;
import com.rxyb.security.service.SysMenuResouceService;
import org.springframework.beans.BeanUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author YJH
 * @version 1.0
 * @description 菜单管理
 * @date 2020/7/9 11:53
 */
@RestController
@RequestMapping(value = "/menu/")
public class MenuResourceController {


    private final SysMenuResouceService sysMenuResouceService;

    public MenuResourceController(SysMenuResouceService sysMenuResouceService) {
        this.sysMenuResouceService = sysMenuResouceService;
    }

    /**
     * 获取数据信息
     *
     * @return
     */
    @PostMapping(value = "menuList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R<MenuListRsp> menuList(@RequestBody MenuListReq req) {
        MenuListRsp rsp = new MenuListRsp();
        BeanUtils.copyProperties(req, rsp);
        return sysMenuResouceService.menuList(req, rsp);
    }


    /**
     * 创建信息
     *
     * @param req
     * @return
     */
    @PostMapping(value = "addMenuResource")
    public R<AddMenuRoleRsp> addMenuRole(@RequestBody AddMenuRoleReq req) {
        AddMenuRoleRsp rsp = new AddMenuRoleRsp();
        BeanUtils.copyProperties(req, rsp);
        return sysMenuResouceService.addMenuRole(req, rsp);
    }
}
